<!DOCTYPE html>
<html>

<head>
 <meta charset="utf-8" />
 <title>{:config('conf.admin_title')}</title>
 {load href="__CSS__/style.css" /}
 <meta name="description" content="lotusadmin">

 <style>
  body {
   height: 100%;
   background: #01AAED;
   overflow: hidden;
  }

  canvas {
   z-index: -1;
   position: absolute;
  }
 </style>
 {load href="__JS__/jquery.min.js" /}
 {load href="__LIB__/layer/layer.js" /}
 {load href="__JS__/verificationNumbers.js" /}
 {load href="__JS__/Particleground.js" /}

</head>

<body>
<dl class="admin_login">
 <dt style="color:white">
  <h1>{:config('conf.admin_title')}</h1>
 </dt>
 <dd class="user_icon">
  <input type="text" name="username" id='username' placeholder="账号" class="login_txtbx" maxlength="16px" />
 </dd>
 <dd class="pwd_icon">
  <input type="password" name="password" id="password" placeholder="密码" class="login_txtbx" maxlength="20px" />
 </dd>

 <dd class="val_icon">
     <div class="checkcode">
         <input type="text" name="code" id="J_codetext" placeholder="验证码" class="login_txtbx" maxlength="5">
     </div>
     <img id="capt" style="width: 112px;height:42px;margin-left: 5px" src="{:url('login/verify')}" alt="captcha" onClick="refresh()" />
 </dd>
 <dd>
  <button id="bs" onclick="login()" type="button" value="立即登陆" class="submit_btn" />立即登陆</button>
 </dd>
</dl>
</body>
<script>
 $(document).ready(function() {
  //粒子背景特效
  $('body').particleground({
   dotColor: '#66CCFF',
   lineColor: '#66CCFF'
  });
 });

 function login() {
  var username = $('#username').val();
  var password = $('#password').val();
  var code_ = $('#J_codetext').val();
  if(username == '' || username == null) {
   layer.msg('用户名不能为空', {icon: 2});
   return;
  }
  if(password == '' || password == null) {
   layer.msg('密码不能为空', {icon: 2});
   return;
  }
  if(code_ == '' || code_ == null) {
      layer.msg('验证码不能为空', {icon: 2});
      return;
  }
  $.ajax({
   url: '/admin/login/login',
   type: 'post',
   dataType: 'json',
   data: {
    username: username,
    password: password,
    code: code_
   },
  }).done(function(data) {
   console.log(data);
   if(data.code == 0) {
    layer.msg(data.msg, {});
    //刷新验证码
	refresh();
   } else {
     layer.msg(data.msg, {
         icon: 1
     }, function() {
        location.href = "/admin/index/index";
	 });

   }
  })
 }
 document.onkeydown = function(e) {
  var ev = document.all ? window.event : e;
  if(ev.keyCode == 13) {
   login();
  }
 }

 function refresh() {
  var code = document.getElementById("capt");
  code.src = '/admin/login/verify.html?' + Math.random();
  $('#J_codetext').val('');
 }
</script>

</html>